package com.xuecheng.teaching.controller;

import com.xuecheng.api.teaching.CompanyAuditApi;
import com.xuecheng.api.teaching.model.CompanyDTO;
import com.xuecheng.api.teaching.model.qo.QueryCompanyModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.teaching.common.utils.UAASecurityUtil;
import com.xuecheng.teaching.service.CompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping
@RestController
public class CompanyAuditColntrollo implements CompanyAuditApi {

    @Autowired
    private CompanyService companyService;

    @PostMapping("m/company/list")
    public PageVO<CompanyDTO> queryCompanyList(PageRequestParams params, @RequestBody QueryCompanyModel model) {

        return companyService.queryCompanyList(params, model);
    }

    @PostMapping("m/company/approve")
    public void approveCompany(@RequestBody CompanyDTO companyDTO) {

        //获得用户名
        String username = UAASecurityUtil.getUser().getUsername();

        companyService.approveCompany(companyDTO,username);
    }
}
